<?php

use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
use Illuminate\Support\Facades\DB;

class CreateCmsCategoriesTable extends Migration
{
    /**
     * Run the migrations.
     *
     * @return void
     */
    public function up()
    {
        if (!Schema::hasTable('cms_categories')) {
            Schema::create('cms_categories', function (Blueprint $table) {
                $table->id();
                $table->integer('parent_id')->default(0)->comment('分类父级id');
                $table->string('name')->comment('分类名称');
                $table->string('slug')->nullable()->comment('分类别名');
                $table->string('description')->comment('分类描述');
                $table->integer('order')->default(0)->comment('排序');
                $table->string('template')->default('default')->comment('模板');
                $table->string('icon')->nullable()->comment('分类图标');
                $table->string('thumb_img')->nullable()->comment('缩略图');
                $table->enum('status', ['ban', 'normal'])->default('normal')->comment('状态:ban禁用,normal正常');
                $table->string('seo_title')->nullable()->comment('标题');
                $table->string('seo_keywords')->nullable()->comment('关键词');
                $table->string('seo_description')->nullable()->comment('描述');
                $table->softDeletes();
                $table->timestamps();
            });
            DB::statement("ALTER TABLE `cms_categories` comment 'CMS分类表'");
        }
    }

    /**
     * Reverse the migrations.
     *
     * @return void
     */
    public function down()
    {
        Schema::dropIfExists('cms_categories');
    }
}
